package Thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created with IntelliJ IDEA.
 * Description: 线程池的使用练习
 */
public class ThreadDemo29 {
    public static void main(String[] args) {
        //创建一个固定数量的线程池，参数就是线程个数
        ExecutorService executors = Executors.newFixedThreadPool(8);
        //创建一个自动扩容的线程池
        //Executors.newCachedThreadPool();
        //创建一个只有一个线程的线程池
        //Executors.newSingleThreadExecutor();
        //创建一个拥有定时器功能的线程池
        //Executors.newScheduledThreadPool();
        for (int i = 0; i < 10; i++) {
            executors.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println("hello");
                }
            });
        }
    }
}
